#include <stdlib.h>
#include <stdio.h>

float clampf(float in, float low, float high) {
	return in > high ? high : in < low ? low : in;
}

float smootherstep(float e0, float e1, float x) {
	x = clampf((x - e0)/(e1 - e0), 0, 1);

	return x*x*x*(x*(x*6 - 15) + 10);
}

int main() {

	int i, sum = 0;
	float now, prev = 0;

	printf("const u8 curve[256] = {\n");

	for (i = 0; i < 256; i++) {
		if (i % 32 == 0)
			printf("\t");

		now = smootherstep(0, 255, i);

		printf("%.0f,", 1 + 1024 * (now - prev));
		sum += 1 + 1024 * (now - prev);

		prev = now;

		if (i % 32 == 31)
			printf("\n");
		else
			printf(" ");
	}

	printf("};\n");
	printf("// sum %u\n",sum);

	return 0;
}
